<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="all">全选</button>
    <button id="none">不选</button>
    <button id="arm">反选</button>
    </br>
    <input id="che1" type="checkbox">
    <input id="che2" type="checkbox">
    <input id="che3" type="checkbox">
    <input id="che4" type="checkbox">
    <input id="che5" type="checkbox">
    <input id="che6" type="checkbox">
    <input id="che7" type="checkbox">
    <input id="che8" type="checkbox">
    <script>
        var inp = document.getElementsByTagName('input')
        all.onclick = function(){
            // 全选
            for(var i = 0;i<inp.length;i++){
                inp[i].checked = true
            }
        }
        // 不选
        none.onclick = function(){
            for(var j = 0;j < inp.length;j++){
                inp[j].checked = false
            }
        }
        // 反选
        arm.onclick = function(){
            for( var h = 0;h < inp.length;h++){
                      inp[h].checked = !inp[h].checked
                       }
                    

            }
    </script>
</body>
</html>